import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex) //vue中使用插件都用Vue.use（）
let defaultCity = '西安'
try{
    if(localStorage.city) {
        defaultCity = localStorage.city
    }
}catch(e){}

//通过vuex创建新仓库
export default new Vuex.Store({
    state: {
        city: defaultCity
    },
    mutations: {
        changeCity (state,city){
            state.city = city
            try {
                localStorage.city = city
            } catch (e) {}            
        }
    }
})